package com.shop2cn.iapi.shenqisettlement.testcase;

import com.shop2cn.iapi.shenqisettlement.parameter.SaveGoodsOwnerSettlementConfigReq;
import com.shop2cn.iapi.shenqisettlement.service.SaveGoodsOwnerSettlementConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.database.model.shenqisettlement.GoodsOwnerSettlementConfig;
import com.ymttest.database.sqlwapper.shenqisettlement.GoodsOwnerSettlementConfigWrapper;
import com.ymttest.utils.TestDataManager;
import org.junit.*;
import org.junit.experimental.categories.Category;

/**
 * 根据国家获取汇率 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_SaveGoodsOwnerSettlementConfig {
	
	private static SaveGoodsOwnerSettlementConfigReq saveGoodsOwnerSettlementConfigReq;
	private static SaveGoodsOwnerSettlementConfigCall saveGoodsOwnerSettlementConfigCall;
	
	GoodsOwnerSettlementConfigWrapper goodsOwnerSettlementConfigWrapper = new GoodsOwnerSettlementConfigWrapper();

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("保存供应商配置");
	}

	@Before
	public void caseUp() {
		saveGoodsOwnerSettlementConfigReq = new SaveGoodsOwnerSettlementConfigReq();
		saveGoodsOwnerSettlementConfigCall = new SaveGoodsOwnerSettlementConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(saveGoodsOwnerSettlementConfigCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	public void verify() {

		GoodsOwnerSettlementConfig actualResult = goodsOwnerSettlementConfigWrapper
				.selectByMerchantId(saveGoodsOwnerSettlementConfigReq
						.getMerchantId());
		
		Logger.verifyEquals(saveGoodsOwnerSettlementConfigReq.getDataId(),
				actualResult.getData_id(), "验证Data_id");
		Logger.verifyEquals(saveGoodsOwnerSettlementConfigReq.getMerchantId(),
				actualResult.getMerchant_id(), "验证Merchant_id");
		Logger.verifyEquals(
				saveGoodsOwnerSettlementConfigReq.getSettlementWay(),
				actualResult.getSettlement_way(), "验证Settlement_way");
		Logger.verifyEquals(
				saveGoodsOwnerSettlementConfigReq.getSettlementPeriodType(),
				actualResult.getSettlement_period_type(),
				"验证Settlement_period_type");
		Logger.verifyEquals(
				saveGoodsOwnerSettlementConfigReq.getSettlementPeriodDay(),
				actualResult.getSettlement_period_day(),
				"验证Settlement_period_day");
		Logger.verifyEquals(saveGoodsOwnerSettlementConfigReq.getAddUser(),
				actualResult.getAdd_user(), "验证Add_user");
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SaveGoodsOwnerSettlementConfig_001() {
		Logger.start(true, "设置货头结算方式成功");
		try {
			
			saveGoodsOwnerSettlementConfigReq.setAddUser((long) TestDataManager
					.getRandomIntNum(8));
			saveGoodsOwnerSettlementConfigReq.setDataId(TestDataManager
					.getRandomNum(9));
			saveGoodsOwnerSettlementConfigReq.setSettlementPeriodDay(0);
			saveGoodsOwnerSettlementConfigReq.setSettlementPeriodType(1);
			saveGoodsOwnerSettlementConfigReq.setSettlementWay(1);
			saveGoodsOwnerSettlementConfigReq
					.setMerchantId((long) TestDataManager.getRandomIntNum(8));
			
			saveGoodsOwnerSettlementConfigCall.setData(saveGoodsOwnerSettlementConfigReq);
			saveGoodsOwnerSettlementConfigCall.callService();

			Logger.verifyEquals(0,
					saveGoodsOwnerSettlementConfigCall.getRetultCode(),
					"验证resultCode");

			this.verify();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}